<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>首页</title>
    <script type="text/javascript" src="/webjars/jquery/3.4.1/dist/jquery.min.js"></script>
    <script>
        $(function () {
            $("tr:even").css("background-color", "pink")
        })

        function del(el, id) {
            var confirm_s = window.confirm("确定删除?");
            if (confirm_s) {
                $.post("ajaxDel", {id: id}, function (falg) {
                    if (falg) {
                        alert("删除成功！");
                        $(el).parent().parent().remove();
                    } else {
                        alert("删除失败！");
                    }
                }, "JSON");
            }
        }
    </script>
    <style>
        tr, td {
            text-align: center;
        }
        a{
            text-decoration: none;
        }
    </style>
</head>
<body>
<table style="margin: 0px auto; width: 500px;" border="0">
    <tr>
        <th colspan="4" align="colspan"><h2>图书信息</h2>
        </th>
    </tr>
    <tr style="line-height:30px;">
        <th colspan="4" align="colspan">
            <form action="search" method="post">
                <span>姓名:</span>
                <input type="text" name="bookName"/>
                <input type="submit" value="查询"/>
            </form>
        </th>
    </tr>
    <tr>
        <th>编号</th>
        <th>书名</th>
        <th>作者</th>
        <th>操作</th>
    </tr>

    <c:forEach items="${bookLostAll}" var="li">
        <tr>
            <td>${li.bookId}</td>
            <td>${li.bookName}</td>
            <td>${li.bookAuthor}</td>
            <td>
                <a href="updateGetBook?bookId=${li.bookId}">修改</a>
                <a href="javascript:void(0);" onclick="del(this,${li.bookId})">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<p style="color:red; text-align: center"><a href="addPage" style="color:red;">新增</a></p>
</body>
</html>
